package 其他.最长相邻不相等子序列I2900;

import java.util.ArrayList;
import java.util.List;

public class Solution {
    public List<String> getLongestSubsequence(String[] words, int[] groups) {
        List<String> ans = new ArrayList<>();
        int n = groups.length;
        for (int i = 0; i < n; i++) {
            if (i == n - 1 || groups[i] != groups[i + 1]) { // i 是连续相同段的末尾
                ans.add(words[i]);
            }
        }
        return ans;
    }
}
